<template>
  <!-- 放置一个图标 -->
  <div class="screenFull">
    <!-- 放置一个 icon 的图标 -->
    <el-tooltip
      class="item"
      effect="dark"
      content="全屏按钮"
      placement="bottom"
    >
      <i
        class="el-icon-full-screen"
        style="color:#fff; width: 30px; height: 30px"
        @click="changeScreen"
      />
    </el-tooltip>
  </div>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  methods: {
    //   改变全屏
    changeScreen () {
      if (!ScreenFull.isEnabled) {
        // 此时全屏不可用
        this.$message.warning('此时全屏组件不可用')
        return
      }
      // document.documentElement.requestFullscreen()  原生js调用
      //   如果可用 就可以全屏
      ScreenFull.toggle()
    }
  }
}
</script>

<style lang="scss">
.screenFull {
  .el-icon-full-screen {
    font-size: 30px;
  }
}
</style>
